/**
*      author: Y_Yao
*      created: 2024-12-14 23:37:01
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
struct node{
    string str;
    int sum;
};
int a,b,c,d,e;
vector<node> ret;
node tmp;

bool cmp(node p1,node p2)
{
    if(p1.sum != p2.sum)
    {
        return p1.sum > p2.sum;
    }
    else return p1.str < p2.str;
}

void solve()
{
    unordered_map<char,int> hash;
    cin >> a >> b >> c >> d >> e;
    hash['A'] = a;
    hash['B'] = b;
    hash['C'] = c;
    hash['D'] = d;
    hash['E'] = e;
    string s = "ABCDE";
    int n = s.size();

    for(int i = 0;i <= (1 << n);i++)
    {
        tmp.str.clear();
        tmp.sum = 0;
        for(int j = 0;j < n;j++)
        {
            if(i & (1 << j))
            {
                tmp.str += s[j];
                tmp.sum += hash[s[j]];
            }
        }
        ret.push_back(tmp);
    }

    sort(ret.begin(),ret.end(),cmp);

    for(auto e : ret)
    {
        cout << e.str << endl;
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}